package com.xpgk.mvc.propgandaThings;

import java.util.List;

import com.jfinal.aop.Before;
import com.xpgk.dto.RenderBean;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.codeSet.Code;
import com.xpgk.mvc.productSet.ProductSetService;
import com.xpgk.mvc.user.User;

public class PropgandaThingsController extends BaseController{
	private PropgandaThingsService propgandaThingsService;
	public void index() {
		render("PropgandaThings.html");
	}

	/**
	 * 产品列表
	 */
	public void productList(){
		
		splitPage.getQueryParam().put(PropgandaThings.column_orgids, getCUserOrganIds());
		String json = paging(splitPage, PropgandaThings.sqlId_splitPageSelect, PropgandaThings.sqlId_splitPageFrom);
		renderJson(json);
	}
	
	/**
	 * 跳转至添加产品
	 */
	public void toAddProduct(){
		
		render("addThings.html");
	}
	
	/**
	 * 添加产品
	 */
	@Before(PropgandaThingsValidator.class)
	public void addProduct(){
		String  cudid=getCUserOrganIds();
		//setAttr("code", Code.cacheGet(ids));
		PropgandaThings product = getModel(PropgandaThings.class);
		RenderBean renderBean = propgandaThingsService.addProduct(product,cudid);
		renderJson(renderBean);
	}
	
	/**
	 * 跳转至编辑
	 */
	public void toUpProduct(){
		setAttr("propgandaThings", PropgandaThings.dao.findById(ids));
		render("upThings.html");
	}
	
	/**
	 * 编辑
	 */
	@Before(PropgandaThingsValidator.class)
	public void upProduct(){
		String  cudid=getCUserOrganIds();
		PropgandaThings product = getModel(PropgandaThings.class);
		RenderBean renderBean = propgandaThingsService.upProduct(product,cudid);
		renderJson(renderBean);
	}
}
